package com.sw.study.monitor;

import com.sw.study.monitor.bean.MethodDataInfo;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class RemoveData implements Runnable {
    private Map<String,List<MethodDataInfo>> methodDataInfos;

    public RemoveData(Map<String,List<MethodDataInfo>> methodDataInfos) {
        this.methodDataInfos = methodDataInfos;
    }

    @Override
    public void run() {
        Long concurrentTime=System.currentTimeMillis()-60000;
        for(Map.Entry<String,List<MethodDataInfo>> entry:methodDataInfos.entrySet()){
            List<MethodDataInfo> list=entry.getValue();
            Iterator<MethodDataInfo> iterator = list.iterator();
            while (iterator.hasNext()){
                if(iterator.next().getEndTimes()<=concurrentTime){
                    iterator.remove();
                }
            }
        }

    }


}
